﻿@model Fap.AspNetCore.ViewModel.JqGridViewModel

<title>
    <fap-multilang lang-key="resume_library" default-content="简历库"></fap-multilang>
</title>

<div class="row">
    <div class="col-xs-12">
        <div class="widget-box">
            <div class="widget-header widget-header-flat">
                <h4 class="widget-title">
                    <fap-multilang lang-key="resume_library" default-content="简历库"></fap-multilang>
                </h4>

                <div class="widget-toolbar">
                    <a href="#" data-action="fullscreen" class="orange2">
                        <i class="ace-icon fa fa-expand"></i>
                    </a>
                </div>
                <div class="widget-toolbar">
                    <fap-button id="btnAddBlacklist" btn-tag="link" content="黑名单" icon-before="fa fa-plus-circle blue" class-name="info"></fap-button>
                    <fap-button id="btnAddTalent" btn-tag="link" content="优才库" icon-before="fa fa-plus-circle blue" class-name="info"></fap-button>
                    <fap-button id="btnAddReserve" btn-tag="link" content="后备人才库" icon-before="fa fa-plus-circle blue" class-name="info"></fap-button>
                </div>
                <div class="widget-toolbar">
                    <fap-button id="btnLinkNewJob" btn-tag="link" content="关联新职位" icon-before="fa fa-link blue" class-name="info"></fap-button>
                </div>
            </div>
            <div class="widget-body">

                <div class="widget-main">
                    <fap-grid id="resume" grid-model="Model" wrapper="widget-main" register-authority="false" oper-chart="true" oper-cud="true" multi-select="true" view-records="true" shrink-fit="false"></fap-grid>

                    <!-- /.row -->
                </div>
            </div>
        </div>
    </div>

</div>

<script>
    var scripts = [null,  null]
    $('.page-content-area').ace_ajax('loadScripts', scripts, function () {
        jQuery(function ($) {
            $(document).one('ajaxloadstart.page', function (e) {
            })
            $("#btnAddBlacklist").on(ace.click_event, function () {
                setResumeStatus('BlackList');
            })
            $("#btnAddTalent").on(ace.click_event, function () {
                setResumeStatus('TalentPool');
            })
            $("#btnAddReserve").on(ace.click_event, function () {
                setResumeStatus('Reserve');
            })
            $("#btnLinkNewJob").on(ace.click_event, function () {
                var rows = getSelectedRows("grid-resume");
                if (rows === null) {
                    return;
                }
                var fids = $.map(rows, function (r) {
                    return r.Fid;
                })
                bootbox.prompt("招聘职位名称", function (result) {
                    if (result !== null && result !== "") {
                        $.post(basePath + "/Recruit/Api/LinkJob", { fids: fids, jobName: result }, function (rv) {
                            if (rv.success) {
                                refreshGrid("grid-resume");
                                $.msg(rv.msg);
                            } else {
                                bootbox.alert(rv.msg);
                            }
                        })
                    }
                });
            })
            var setResumeStatus = function (status) {
                var rows = getSelectedRows("grid-resume");
                if (rows === null) {
                    return;
                }
                var fids = $.map(rows, function (r) {
                    return r.Fid;
                })
                bootbox.confirm("确定要执行此操作吗?", function (result) {
                    if (result) {
                        $.post(basePath + "/Recruit/Api/ResumeStatus", { fids: fids, status: status }, function (rv) {
                            if (rv.success) {
                                $.msg(rv.msg);
                                refreshGrid("grid-resume");
                            } else {
                                bootbox.alert(rv.msg);
                            }
                        })
                    }
                })
            };
        })
    })
</script>